import 'package:flutter/material.dart';

class GridViewPage extends StatelessWidget {
  const GridViewPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text('GridView'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(20.0),
        child: buildGridView(),
      ),
    );
  }



  GridView buildGridView(){
    return GridView.builder(gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3,mainAxisSpacing: 10,crossAxisSpacing: 10), itemBuilder: (context,index){
      return Container(
        alignment: Alignment.center,
        decoration: BoxDecoration(
            color: Colors.deepPurple,
            borderRadius: BorderRadius.circular(8)
        ),
        width: 100,height: 100,child: Text("第$index个item",style: const TextStyle(fontSize: 16,color: Colors.white),),);
    },itemCount: 100,);
  }
}
